///
/// UpdateRecord makes use of Web Service to update a record.
///
/// The table to update a record in.
/// The id used to identify the record that will be updated.
/// Function
/// Nothing, or the new of the inserted record.
public override void UpdateRecord(
BaseClasses.Data.TableDefinition table,
BaseClasses.Data.KeyValue recordId,
BaseClasses.Data.RecordValue recValue,
bool[] columnsChanged)
{
int ${Primary Key} = -1;
string ${First Updatable Field} = "";
string ${Second Updatable Field} = "";
// Get the instance of the data access class.
${${Table Name}ClassName} myTable;
myTable = ${${Table Name}ClassName}.Instance;
foreach (BaseClasses.Data.BaseColumn col in table.ColumnList)
{
int index = table.ColumnList.IndexOf(col);
if (col.InternalName == myTable.${First Updatable Field}Column.InternalName)
{
// Set value of ${First Updatable Field}.
${First Updatable Field} = col.ToDatabaseValue(recValue.ColumnValues[index]).ToString();
}
else if (col.InternalName == myTable.${Second Updatable Field}Column.InternalName)
{
// Set value of ${Second Updatable Field}.
${Second Updatable Field} = col.ToDatabaseValue(recValue.ColumnValues[index]).ToString();
}
else if (col.InternalName == myTable.${Primary Key}Column.InternalName)
{
// Set value of ${Primary Key}.
${Primary Key} = System.Convert.ToInt32(col.ToDatabaseValue(recValue.ColumnValues[index]).ToString());
}
}
// Instantiate the object that will communicate with a web service.
// Replace MyWebServiceForTableAccess with the external Web Service name
localhost.MyWebServiceForTableAccess webService;
webService = new localhost.MyWebServiceForTableAccess();
webService.Credentials = System.Net.CredentialCache.DefaultCredentials;
// Call the web service's "UpdateRecord" function.
webService.Update${${Table Name}RecordClassName}(${Primary Key}, ${First Updatable Field}, ${Second Updatable Field});
}
|